package com.zide.link.controller;

import java.util.List;

import com.zide.common.core.vo.CommonParamIdVO;
import com.zide.link.domain.vo.result.LinkSearchResultVO;
import com.zide.link.domain.vo.save.LinkSearchSaveVO;
import com.zide.link.domain.vo.search.LinkSearchSearchVO;
import com.zide.link.service.ILinkSearchService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zide.common.core.domain.PageResult;
import com.zide.common.core.domain.CommonResult;
import static com.zide.common.core.domain.CommonResult.getResult;
import static com.zide.common.core.domain.CommonResult.success;

/**
 * 搜索引擎Controller
 * 
 * @author zide
 * @date 2024-05-10
 */
@Tag(name = "搜索引擎")
@RestController
@RequestMapping("/link/search")
public class LinkSearchController {
    @Resource
    private ILinkSearchService linkSearchService;


    @Operation(summary = "查询搜索引擎列表")
    @GetMapping("/list")
    public CommonResult list(LinkSearchSearchVO searchVO) {

        List<LinkSearchResultVO> list = linkSearchService.searchLinkList(searchVO);
        return success(list);
    }


    @Operation(summary = "获取搜索引擎详细信息")
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id) {
        return success(linkSearchService.selectLinkSearchById(id));
    }

    @Operation(summary = "新增搜索引擎")
    @PostMapping
    public CommonResult add(@RequestBody LinkSearchSaveVO saveVO) {
        return getResult(linkSearchService.saveLinkSearch(saveVO));
    }

    @Operation(summary = "修改搜索引擎")
    @PutMapping
    public CommonResult edit(@RequestBody LinkSearchSaveVO saveVO){
        return getResult(linkSearchService.updateLinkSearch(saveVO));
    }

    @Operation(summary = "修改搜索引擎")
    @PutMapping("status")
    public CommonResult updateStatus(@RequestBody LinkSearchSaveVO saveVO){
        return getResult(linkSearchService.updateStatus(saveVO));
    }

    @Operation(summary = "删除搜索引擎")
	@DeleteMapping
    public CommonResult remove(@RequestBody CommonParamIdVO idVO){
        return getResult(linkSearchService.removeLinkSearchByIds(idVO));
    }
}
